import Vue from "vue"
import loading from "@/components/loading/Loading.vue"


const createLoading = Vue.extend(loading)
const newLoading = new createLoading({
    el: document.createElement("div")
})

newLoading.show = false


const $loading = {
    show() {
        newLoading.show = true
        document.body.appendChild(newLoading.$el)
    },
    hide() {
        newLoading.show = false
    }
}

export default {
    install() {
        if (!Vue.$loading) {
            Vue.$loading = $loading
        }
        Vue.mixin({
            created() {
                this.$loading = Vue.$loading
            }
        })
    }
}